var linkImageUrl = 'http://211.149.190.104:80/ad/6/ad.jpg';  
var lineLink=window.location.href;
if(lineLink.indexOf('?')>1){
    }else{
    	lineLink+="?g=1";
	}
if(lineLink.indexOf("code")>1){
	var s=lineLink.split("?");
	lineLink=s[0]+"?fenxiang=1&shopId="+_shopId+"&openId="+_openId;
}
if(lineLink.indexOf("fenxiang")>1){
	
}else{
	lineLink+="&fenxiang=1";
}
var descContent = "";  
var shareTitle = document.title;  
var appid = 'wxc9937e3a66af6dc8'; 
$(function(){
	 linkImageUrl = 'http://211.149.190.104:80/ad/6/ad.jpg';  
	 lineLink=window.location.href;
	if(lineLink.indexOf('?')>1){
	    }else{
	    	lineLink+="?g=1";
		}
	if(lineLink.indexOf("code")>1){
		var s=lineLink.split("?");
		lineLink=s[0]+"?fenxiang=1&shopId="+_shopId+"&openId="+_openId;
	}
	if(lineLink.indexOf("fenxiang")>1){
		
	}else{
		lineLink+="&fenxiang=1";
	}
	 descContent = "";  
	 shareTitle = document.title;  
	 appid = 'wx8573b913ca871dc3';
	 getFenXiang();
});
function shareFriend() {
	    WeixinJSBridge.invoke('sendAppMessage',{  
                            "appid": appid,  
                            "img_url": linkImageUrl,  
                            "img_width": "640",  
                            "img_height": "640",  
                            "link": lineLink,  
                            "desc": descContent,  
                            "title": shareTitle  
                            }, function(res) {  
                            _report('send_msg', res.err_msg);  
                            });  
}  
function shareTimeline() {  
    WeixinJSBridge.invoke('shareTimeline',{  
                            "img_url": linkImageUrl,  
                            "img_width": "640",  
                            "img_height": "640",  
                            "link": lineLink,  
                            "desc": descContent,  
                            "title": shareTitle  
                            }, function(res) {  
                            _report('timeline', res.err_msg);  
                            });  
}  
function shareWeibo() {  
    WeixinJSBridge.invoke('shareWeibo',{  
                            "content": descContent,  
                            "url": lineLink,  
                            }, function(res) {  
                            _report('weibo', res.err_msg);  
                            });  
}  
// 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。  
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {  
  
        // 发送给好友  
        WeixinJSBridge.on('menu:share:appmessage', function(argv){  
            shareFriend();  
            });  
  
        // 分享到朋友圈  
        WeixinJSBridge.on('menu:share:timeline', function(argv){  
            shareTimeline();  
            });  
  
        // 分享到微博  
        WeixinJSBridge.on('menu:share:weibo', function(argv){  
            shareWeibo();  
            });  
        }, false); 
function getFenXiang(){
	var fenxiang = getIdByName("fenxiang");
	if(fenxiang==1){
		/*  var ua = navigator.userAgent.toLowerCase();
		if(ua.match(/MicroMessenger/i)=="micromessenger") {
		 */	pinglunDianz(9);
		    /* } else {
				return false;
		    } */
	}
}

/*function getIp(){
	
	var ip = 0;
	var dt = _findInfo("../../../wechat/testip2", null);
	if(IsNotEmpty(dt)&&dt.state==0){
		 ip=getHeadIndexValue(0, dt, "ip");
		 pinglunDianz(ip);
		}
}*/

function pinglunDianz(ip){
	var url = 	window.location.href;
	var heads = new Array("openId","url","ip","shopId");
	var datas = new Array(_openId,url,ip,_shopId);
	var parser = new Object();
	var jsonParserStr = null;
	if (IsNotEmpty(datas)){
		addToParser(heads, datas, "add" , parser);
		jsonParserStr =  JSON.stringify(parser);
	}
	var dt = _PostInfoRstNoMessage("../../../shareDiscuss/insert/insertInfo", {'data':jsonParserStr});
	if(IsNotEmpty(dt)&&dt.state==0){
	}
}